<template>
	<div style="height:3000px">
		<!-- 工单领料 -->

			<v-card>
				<v-card-title>
					<v-row >
						<v-col cols="3">
							<!--<v-btn class="ml-2"  tile color="primary" @click.stop="AddDialog()">
								新增
							</v-btn>-->
							<!--<v-btn class="ml-2"  tile color="error" @click.stop="deleteOrder()">
								删除
							</v-btn>-->
							<v-btn class="ml-2"  tile color="success" @click.stop="OutInv()">
								选择出库
							</v-btn>
						</v-col>
						<v-col cols="8" >
								<v-row >
									<v-col cols="2" >
										<v-text-field label="单据号" v-model="Ssourceorder" placeholder="单据号" dense outlined>
										</v-text-field>
									</v-col>
										
									<v-col cols="2" >
										<v-text-field label="物料代码" v-model="Sitemcode" placeholder="物料代码" dense outlined>
										</v-text-field>
									</v-col>
									
									<v-col cols="2" >
										<v-text-field label="物料名称" v-model="Sitemname" placeholder="物料名称" dense outlined>
										</v-text-field>
									</v-col>
								
									<v-col cols="2" >
										<v-text-field label="项目号" v-model="Sproject" placeholder="项目号" dense outlined>
										</v-text-field>
									</v-col>
									
									<v-col cols="2">
										<v-select  v-model="flagselect" :items="flagitems"
															item-text="name"
										          item-value="value"
											outlined dense label="完成标识">
										</v-select>
									</v-col>
									
									<v-col cols="2">
										<v-btn depressed color="primary" @click="searchinfo()" tile>查询</v-btn>
									</v-col>
								</v-row>																												
						</v-col>
						
						<v-col cols="1" align="end">
							<v-btn dark color="blue lighten-3" @click="refreshApps">
								<v-icon dark>mdi-refresh-circle</v-icon>刷新
							</v-btn>
						</v-col>
						
					</v-row>					
				</v-card-title>
				
				<v-alert dense text color="blue-grey"></v-alert>
				
				<v-data-table :headers="HeaderList" :items="DataList" small dense
					fixed-header item-key="id"  class="text-no-wrap" show-select  v-model="selected"
					loading-text="正在加载请稍等......" :loading="HOrderLoading"
					:options.sync="HOrderOptions" :footer-props="vuetifyDefaultPage"
					:server-items-length="HOrderTotalCount"
					show-expand  single-expand @item-expanded="getdetails">
					<template v-slot:item.state="{ item }">
						<v-chip v-if="item.state == 0" small label
							
						>
							新建
						</v-chip>
						<v-chip v-else-if="item.state == 1" color="accent" small label
							
						>
							正在执行
						</v-chip>
						<v-chip v-else-if="item.state == 2" color="primary" small label
							
						>
							已完成
						</v-chip>
						<v-chip v-else color="error" small label
							
						>
							已取消
						</v-chip>
					</template>
					<template v-slot:item.type="{ item }">
						<v-chip v-if="item.type == 1" color="primary" small label
							
						>
							领料出库单
						</v-chip>
						<v-chip v-else-if="item.type == 2" color="primary" small label
							
						>
							发货出库单
						</v-chip>
						<v-chip v-else color="primary" small label
							
						>
							其他出库单
						</v-chip>
					</template>
					<template v-slot:item.stockedflag="{ item }">
						<v-chip v-if="item.stockedflag == 0" small label color="error"
							
						>
							未完成
						</v-chip>
						<v-chip v-else color="primary" small label
							
						>
							已完成
						</v-chip>
					</template>
					<template v-slot:item.feedbackflag="{ item }">
						<v-chip v-if="item.feedbackflag == 0" small label color="error"
							
						>
							未过账
						</v-chip>
						<v-chip v-else color="primary" small label
							
						>
							已过账
						</v-chip>
					</template>
					<template v-slot:item.actions="{ item }">
			      <v-btn tile color="warning" small @click.stop="EditDialog(item)">
							<v-icon left>
								mdi-pencil
							</v-icon>
							编辑
			      </v-btn>
			    </template>
					<template v-slot:expanded-item="{ headers, item }">
						
						<td :colspan="headers.length">
							<v-data-table :headers="DetailsBodyList" :items="DetailsList" small dense
								fixed-header item-key="id"  class="text-no-wrap"
								loading-text="正在加载请稍等......" :loading="DOrderLoading"
								:options.sync="DOrderOptions" :footer-props="vuetifyDefaultPage"
								:server-items-length="DOrderTotalCount">
								<template v-slot:item.feedbackflag="{ item }">
									<v-chip v-if="item.feedbackflag == 0"  color="error" small label
										
									>
										未过账
									</v-chip>
									<v-chip v-else color="primary" small label
										
									>
										已过账
									</v-chip>
								</template>
								<template v-slot:item.actions="{ item }">
									<v-row>										
										<!--<v-col cols="6">
											<v-btn tile color="warning" small @click.stop="">
												<v-icon left>
													mdi-pencil
												</v-icon>
												过账
											</v-btn>
										</v-col>-->
										
										<v-col cols="6">
											<v-btn tile color="error" small @click.stop="DeleteDetails(item)">
												<v-icon left>
													mdi-pencil
												</v-icon>
												删除
											</v-btn>
										</v-col>
									</v-row>
								</template>
								</v-data-table>								
						</td>
					</template>
				</v-data-table>

			</v-card>
	
	

		<!-- 对话框 -->
		<v-dialog v-model="AddOrEditDialog" max-width="1000px">
			<v-card>
				<v-card-title class="text-h5">
				  {{DialogHeader}}
				</v-card-title>
				<v-card-text>
				  <div class="mb-12">
				  	<v-row dense>
				  		<v-col cols="12">
				  			<v-row>
									<v-col cols="6">
										<v-text-field label="单据编号"  clearable :rules="[rules.required]"
											v-model="DialogBill.sourceorder">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-select  v-model="DialogBill.type" :items="Stype"
															item-text="name"
										          item-value="value"
											 label="单据类型">
										</v-select>
									</v-col>
									<v-col cols="6">
										<v-text-field label="项目号"  clearable :rules="[rules.required]"
											v-model="DialogBill.project">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="物料编号"  clearable :rules="[rules.required]"
											v-model="DialogBill.itemcode">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="物料名称"  clearable :rules="[rules.required]"
											v-model="DialogBill.itemname">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="规格"  clearable :rules="[rules.required]"
											v-model="DialogBill.spec">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="数量"  clearable :rules="[rules.required]" 
											v-model="DialogBill.qty">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="单位"  clearable :rules="[rules.required]" 
											v-model="DialogBill.unit">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="出库数量"  clearable :rules="[rules.required]" 
											v-model="DialogBill.oqty">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="批次"  clearable :rules="[rules.required]" 
											v-model="DialogBill.lot">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="仓库"  clearable :rules="[rules.required]" 
											v-model="DialogBill.warehouse">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="库区"  clearable :rules="[rules.required]" 
											v-model="DialogBill.zonecode">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-text-field label="库位"  clearable :rules="[rules.required]" 
											v-model="DialogBill.location">
										</v-text-field>
									</v-col>
									<v-col cols="6">
										<v-select  v-model="DialogBill.state" :items="Sstate"
															item-text="name"
										          item-value="value"
											 label="状态">
										</v-select>
									</v-col>
				  				<v-col cols="6">
										<v-select  v-model="DialogBill.stockedflag" :items="Sstockedflag"
															item-text="name"
										          item-value="value"
											 label="是否完成">
										</v-select>
				  				</v-col>
									<v-col cols="6">
										<v-select  v-model="DialogBill.feedbackflag" :items="Sfeedbackflag"
															item-text="name"
										          item-value="value"
											 label="是否过账">
										</v-select>
									</v-col>
				  			</v-row>
				  		</v-col>
				  	</v-row>
				  </div>
				</v-card-text>
				<v-card-actions>
				  <v-spacer></v-spacer>
					
				  <v-btn
				    color="green darken-1"
				    text
				    @click="confirmOrder()"
				  >
				    提交
				  </v-btn>
					
				  <v-btn
				    color="green darken-1"
				    text
				    @click="AddOrEditDialog = false"
				  >
				    关闭
				  </v-btn>
				</v-card-actions>
			</v-card>
		</v-dialog>
		
		
		<!-- 对话框 -->
		<v-dialog v-model="PutOutDialog" max-width="1000px">
			<v-card>
				<v-card-title class="text-h5">
				  选择一条库存
				</v-card-title>
				<v-card-text>
				  <div class="mb-12">
				  	<v-row dense>
				  		<v-col cols="12">
				  			<v-row>
									<v-col cols="12">
										<v-data-table :headers="PutOutList" :items="PutOutDataList" small dense
											fixed-header item-key="id"  class="text-no-wrap" show-select single-select  v-model="Pselected"
										 loading-text="正在加载请稍等......" :loading="POrderLoading"
										 :options.sync="POrderOptions" :footer-props="vuetifyDefaultPage"
										 :server-items-length="POrderTotalCount">
											<template v-slot:item.type="{ item }">
												<v-chip v-if="item.type == 1" color="primary" small label
													
												>
													采购入库单
												</v-chip>
												<v-chip v-else-if="item.type == 2" color="primary" small label
													
												>
													生产入库单
												</v-chip>
												<v-chip v-else color="primary" small label
													
												>
													其他入库单
												</v-chip>
											</template>
											
											<template v-slot:item.pass="{ item }">
												<v-chip v-if="item.pass == 0" color="error" small label
													
												>
													不合格
												</v-chip>
												<v-chip v-else color="success" small label
													
												>
													合格
												</v-chip>
											</template>
										</v-data-table>
									</v-col>
				  			</v-row>
				  		</v-col>
				  	</v-row>
				  </div>
				</v-card-text>
				<v-card-actions>
				  <v-spacer></v-spacer>
					
				  <v-btn
				    color="green darken-1"
				    text
				    @click="CommitInv()"
				  >
				    提交
				  </v-btn>
					
				  <v-btn
				    color="green darken-1"
				    text
				    @click="PutOutDialog = false"
				  >
				    关闭
				  </v-btn>
				</v-card-actions>
			</v-card>
		</v-dialog>
		
		<v-dialog v-model="deldialog" class="text-center" width="300px">
			<v-card >
						<v-card-title>提示</v-card-title>
						<v-card-text>
							您确定要删除吗？
						</v-card-text>
						<v-card-actions>
							<v-col cols="8">
								<v-btn @click="SureDeleteDetails()" color="error">确定</v-btn>
							</v-col>
							<v-col cols="4">
								<v-btn @click="deldialog = false">取消</v-btn>
							</v-col>						
						</v-card-actions>
			</v-card>
		</v-dialog>
	</div>
</template>

<script>
export default {
  name: 'wms_operations_picktake',
  data: () => ({
		  Ssourceorder:'',
			Sitemcode:'',
			Sitemname:'',
			Sproject:'',
			flagselect:-1,
			flagitems:[
				{name: '所有', value:-1},
				{name: '禁用', value:0},
				{name: '可用', value:1},
			],
			Sstockedflag:[
				{name: '未完成', value:0},
				{name: '已完成', value:1},
			],
			Sfeedbackflag:[
				{name: '未过账', value:0},
				{name: '已过账', value:1},
			],
			Sstate:[
				{name: '新建', value:0},
				{name: '正在执行', value:1},
				{name: '已完成', value:2},
				{name: '已取消', value:3},
			],
			Stype:[
				{name: '领料出库单', value:1},
				{name: '发货出库单', value:2},
				{name: '其他出库单', value:3},
			],
  		AddOrEditDialog: false,
			DetailsDialog:false,
			PutOutDialog:false,
			deldialog:false,
			delitem:"",
  		HeaderList: [
  			{ text: '单据编号',value: 'sourceorder'},
  			{ text: '单据类型', value: 'type' },
				{ text: '项目号', value: 'project' },
				{ text: '物料编号', value: 'itemcode' },
  			{ text: '物料名称', value: 'itemname' },
				{ text: '规格', value: 'spec' },
				{ text: '数量', value: 'qty' },
				{ text: '剩余数量', value: 'oqty' },
				{ text: '单位', value: 'unit' },
				{ text: '批次', value: 'lot' },
				{ text: '仓库', value: 'warehouse' },
				{ text: '库区', value: 'zonecode' },
				{ text: '库位', value: 'location' },
				{ text: '状态', value: 'state' },
				{ text: '过账标识', value: 'feedbackflag' },
				{ text: '完成标识', value: 'stockedflag' },
				{ text: '完成时间', value: 'stockedtime' },
				{ text: '创建人', value: 'created_byname' },
				{ text: '创建时间', value: 'created_time' },
				{ text: '编辑人', value: 'updated_byname' },
				{ text: '编辑时间', value: 'updated_time' },
				{ text: '操作', value: 'actions' },
  		],
			DetailsBodyList:[
				{ text: '仓库', value: 'warehouse' },
				{ text: '库区', value: 'zonecode' },
				{ text: '库位', value: 'location' },
				/*{ text: '过账标识', value: 'feedbackflag' },
				{ text: '过账时间', value: 'feedbacktime' },*/
				{ text: '操作', value: 'actions' },	
			],
			PutOutList:[
				
					{ text: '单据编号',value: 'sourceorder'},
					{ text: '单据类型', value: 'type' },
					{ text: '项目号', value: 'project' },
					{ text: '物料编号', value: 'itemcode' },
					{ text: '物料名称', value: 'itemname' },
					{ text: '规格', value: 'spec' },
					{ text: '数量', value: 'qty' },
					{ text: '单位', value: 'unit' },
					{ text: '批次', value: 'lot' },
					{ text: '仓库', value: 'warehouse' },
					{ text: '库区', value: 'zonecode' },
					{ text: '库位', value: 'location' },
					{ text: '托盘', value: 'container' },
					{ text: '合格标识', value: 'pass' },
				
			],
			PutOutDataList:[],
			DialogBill:{
				id:'',
				dbid:'',
				isavailable:true,
				created_by:'',
				created_byname:'',
				updated_by:'',
				updated_byname:'',
				company:'',
				created_time:'',
				updated_time:'',	
				accountingbookcode:'',
						
				sourceorder:'',
				type:1,
				project:'',
				itemcode:'',
				itemname:'',	
					spec:'',
				qty:'',
				oqty:'',
				unit:'',
				lot:'',
				warehouse:'',
				zonecode:'',
				location:'',
				state:0,
				stockedflag:0,
				feedbackflag:0,
			},
			DetailsBill:{
				id:'',
				dbid:'',
				isavailable:true,
				created_by:'',
				created_byname:'',
				updated_by:'',
				updated_byname:'',
				company:'',
				created_time:'',
				updated_time:'',	
				accountingbookcode:'',
				
				fatherid:'',		
				warehouse:'',
				zonecode:'',
				location:'',
				feedbackflag:0,
				feedbacktime:'',
			},
  		DataList: [],
			DetailsList: [],
			selected:[],
			Pselected:[],
  		checkList: [],
			vuetifyDefaultPage: {
				'items-per-page-text': '每页个数',
				'items-per-page-options': [10, 20, 50, 100]
			},
			HOrderLoading: true,
			HOrderTotalCount: 0,
			HOrderOptions: {
				//页数
				page: 1,
				//每页行数
				itemsPerPage: 10
			},
			DOrderLoading: true,
			DOrderTotalCount: 0,
			DOrderOptions: {
				//页数
				page: 1,
				//每页行数
				itemsPerPage: 10
			},
			POrderLoading: true,
			POrderTotalCount: 0,
			POrderOptions: {
				//页数
				page: 1,
				//每页行数
				itemsPerPage: 10
			},
			DialogHeader:"",
			DetailsDialogHeader:"",
  		leftCheckMaterialValid: false,
  		//领料单 表单信息
  		leftMaterialRequestOrderModel: {},
  		leftMaterialValid: true,
  		//领料单 需要数量规则
  		rules: {
  		    required: value => !!value || '值不能为空！',
  		    counter: value => value.length <= 20 || '字符长度不能超过20!',
  				num: value => value > 0 || '值要大于0！',
  				true: value => {
  					const pattern = /^[0-9]*$/
  					return pattern.test(value) || '请输入合法数字!'
  				}
  		 },
			 SelectID:"",
  	}),
		watch: {
			HOrderOptions: {
				handler() {
					this.loadDataList()
				},
				deep: true
			},
			DOrderOptions: {
				handler() {
					this.loaddetails()
				},
				deep: true
			},
			POrderOptions: {
				handler() {
					this.loadPutOutDataList()
				},
				deep: true
			},
		},
		
  	created() {  
			//获取单据信息
  		this.loadDataList()
  	},
  	methods: {
  		//搜索
  		search() {
  			this.loadCuttingDetailList()
  		},
  		//加载单据信息
  		loadDataList() {
  			var that = this;
				that.HOrderLoading = true;
				that.DataList = [];
  			this.$httpRequest({
  				url: `WMS/WmsBillPutOutDetailsBody/GetBillListByPage?pageIndex=${this.HOrderOptions.page}&pageSize=${this.HOrderOptions.itemsPerPage}`,
  				method: 'get'
  			}).then(function(response) {
  				if (response.status == 1) {
  					that.DataList = response.data.result;
						that.HOrderTotalCount = response.data.pagination.totalRecords;
						that.HOrderLoading = false;
  				} else {
  					that.$message.error(response.info);
  				}
  			})
  		},
  		// 打开编辑对话框
  		EditDialog(item) {
				this.DialogBill.id = item.id;
				this.DialogBill.dbid = item.dbid;
				this.DialogBill.isavailable = item.isavailable;
				this.DialogBill.created_by = item.created_by;
				this.DialogBill.created_byname = item.created_byname;
				this.DialogBill.updated_by = item.updated_by;
				this.DialogBill.updated_byname = item.updated_byname;
				this.DialogBill.company = item.company;
				this.DialogBill.created_time = item.created_time;
				this.DialogBill.updated_time = item.updated_time;
				this.DialogBill.accountingbookcode = item.accountingbookcode;
				this.DialogBill.sourceorder = item.sourceorder;
				this.DialogBill.type = item.type;
				this.DialogBill.project = item.project;
				this.DialogBill.itemcode = item.itemcode;
				this.DialogBill.itemname = item.itemname;
				this.DialogBill.spec = item.spec;
				this.DialogBill.lot = item.lot;
				this.DialogBill.qty = item.qty;
				this.DialogBill.oqty = item.oqty;
				this.DialogBill.unit = item.unit;
				this.DialogBill.warehouse = item.warehouse;
				this.DialogBill.zonecode = item.zonecode;
				this.DialogBill.location = item.location;
				this.DialogBill.state = item.state;
				this.DialogBill.stockedflag = item.stockedflag;
				this.DialogBill.feedbackflag = item.feedbackflag;
				this.DialogHeader = "编辑拣配单";
				this.AddOrEditDialog = true;
  		},
			// 打开新增对话框
			AddDialog() {
				this.DialogBill.sourceorder = "";
				this.DialogBill.type = "";
				this.DialogBill.project = "";
				this.DialogBill.itemcode = "";
				this.DialogBill.itemname = "";
				this.DialogBill.spec = "";
				this.DialogBill.lot = "";
				this.DialogBill.qty = "";
				this.DialogBill.oqty = "";
				this.DialogBill.unit = "";
				this.DialogBill.warehouse = "";
				this.DialogBill.zonecode = "";
				this.DialogBill.location = "";
				this.DialogBill.state = "";
				this.DialogBill.stockedflag = 0;
				this.DialogBill.feedbackflag = 0;
				this.DialogHeader = "新增拣配单";
				this.AddOrEditDialog = true;
			},
  		//提交
  		confirmOrder() {
  			var that = this;
				if(that.DialogHeader == "新增拣配单")
				{
					this.$httpRequest({
						url: `/WMS/WmsBillPutOutDetailsBody/Add`,
						method: 'post',
						data:{					
								sourceorder : that.DialogBill.sourceorder,
								type : that.DialogBill.type,
								project : that.DialogBill.project,
								itemcode : that.DialogBill.itemcode,
								itemname : that.DialogBill.itemname,
								spec : that.DialogBill.spec,
								lot : that.DialogBill.lot,
								qty : that.DialogBill.qty,
								oqty : that.DialogBill.oqty,
								unit : that.DialogBill.unit,
								warehouse : that.DialogBill.warehouse,
								zonecode : that.DialogBill.zonecode,
								location : that.DialogBill.location,
								state : that.DialogBill.state,
								stockedflag : that.DialogBill.stockedflag,
								feedbackflag : that.DialogBill.feedbackflag,
						}
					}).then(function(response) {
					
						if (response.status == 1) {
							that.loadDataList();
							that.AddOrEditDialog = false;
							that.$message.success("新增拣配单成功！");
						} else {
							that.$message.error(response.info);
						}
					})
				}
				else
				{
					this.$httpRequest({
						url: `/WMS/WmsBillPutOutDetailsBody/Update`,
						method: 'post',
						data:{		
								id : that.DialogBill.id,
								dbid : that.DialogBill.dbid,
								isavailable : that.DialogBill.isavailable,
								created_by : that.DialogBill.created_by,
								created_byname : that.DialogBill.created_byname,
								updated_by : that.DialogBill.updated_by,
								updated_byname : that.DialogBill.updated_byname,
								company : that.DialogBill.company,
								created_time : that.DialogBill.created_time,
								updated_time : that.DialogBill.updated_time,
								accountingbookcode : that.DialogBill.accountingbookcode,
								sourceorder : that.DialogBill.sourceorder,
								type : that.DialogBill.type,
								project : that.DialogBill.project,
								itemcode : that.DialogBill.itemcode,
								itemname : that.DialogBill.itemname,
								spec : that.DialogBill.spec,
								lot : that.DialogBill.lot,
								qty : that.DialogBill.qty,
								oqty : that.DialogBill.oqty,
								unit : that.DialogBill.unit,
								warehouse : that.DialogBill.warehouse,
								zonecode : that.DialogBill.zonecode,
								location : that.DialogBill.location,
								state : that.DialogBill.state,
								stockedflag : that.DialogBill.stockedflag,
								feedbackflag:that.DialogBill.feedbackflag,
						}
					}).then(function(response) {
					
						if (response.status == 1) {
							that.loadDataList();
							that.AddOrEditDialog = false;
							that.$message.success("编辑拣配单成功！");
						} else {
							that.$message.error(response.info);
						}
					})
				}
  			
  		},
  		//取消 取消领料单
  		cancelOrder() {
  			this.AddOrEditDialog = false;
  		},
			deleteOrder(){
				var that = this;
				for(var i=0; i<that.selected.length; i++)
				{
					this.$httpRequest({
						url: `/WMS/WmsBillPutOutDetailsBody/Delete/${that.selected[i].id}`,
						method: 'delete'											
					}).then(function(response) {					
						if (response.status == 1) {							
							that.$message.success("删除成功！");							
						} else {
							that.$message.error("删除失败！");
						}
					})
				}
				that.loadDataList();
			},
			searchinfo(){
				var that = this;
				that.HOrderLoading = true;
				that.DataList = [];
				this.$httpRequest({
					url: `WMS/WmsBillPutOutDetailsBody/Search?Ssourceorder=${this.Ssourceorder}&Sitemcode=${this.Sitemcode}&Sitemname=${this.Sitemname}&Sproject=${this.Sproject}&Sflag=${this.flagselect}&pageIndex=${this.HOrderOptions.page}&pageSize=${this.HOrderOptions.itemsPerPage}`,
					method: 'get'
				}).then(function(response) {
					if (response.status == 1) {
						that.DataList = response.data.result;
						that.HOrderTotalCount = response.data.pagination.totalRecords;
						that.HOrderLoading = false;
					} else {
						that.$message.error(response.info);
					}
				})
			},
			refreshApps(){
				this.Ssourceorder = "";
				this.Sitemcode = "";
				this.Sitemname = "";
				this.Sproject = "";
				this.flagselect = -1;
				this.selected = [];
				this.HOrderOptions.page = 1;
				this.loadDataList();
			},
			//加载明细
			getdetails(item){
				this.SelectID = item.item.id;
				var that = this;
				that.DOrderLoading = true;
				that.DetailsList = [];
				this.$httpRequest({
					url: `WMS/WmsBillPutOutLocation/GetBillListByPage?id=${item.item.id}&pageIndex=${this.DOrderOptions.page}&pageSize=${this.DOrderOptions.itemsPerPage}`,
					method: 'get'
				}).then(function(response) {
					if (response.status == 1) {
						that.DetailsList = response.data.result;
						that.DOrderTotalCount = response.data.pagination.totalRecords;
						that.DOrderLoading = false;
					} else {
						that.$message.error(response.info);
					}
				})
			},
			//刷新明细
			loaddetails(){
				var that = this;
				that.DOrderLoading = true;
				that.DetailsList = [];
				this.$httpRequest({
					url: `WMS/WmsBillPutOutLocation/GetBillListByPage?id=${this.SelectID}&pageIndex=${this.DOrderOptions.page}&pageSize=${this.DOrderOptions.itemsPerPage}`,
					method: 'get'
				}).then(function(response) {
					if (response.status == 1) {
						that.DetailsList = response.data.result;
						that.DOrderTotalCount = response.data.pagination.totalRecords;
						that.DOrderLoading = false;
					} else {
						that.$message.error(response.info);
					}
				})
			},
			//删除明细
			DeleteDetails(item)
			{
				this.deldialog = true;
				this.delitem = item.id;
							
			},
			SureDeleteDetails()
			{
				var that = this;
				this.$httpRequest({
					url: `/WMS/WmsBillPutOutLocation/Delete/${that.delitem}`,
					method: 'delete'	
				}).then(function(response){
					if(response.status == 1)
					{
						that.$message.success("删除明细成功！");		
					} else {
						that.$message.error("删除明细失败！");
					}
				})
				that.loaddetails();	
				that.deldialog = false;
				this.refreshApps();
			},
			OutInv(){
				if(this.selected.length == 0)
				{
					this.$message.error("请选择1条信息！");	
				}
				else if(this.selected.length > 1)
				{
					this.$message.error("请不要多选！");	
				}
				else
				{
					this.PutOutDialog = true;	
					this.loadPutOutDataList();
				}
			},
			//加载待入库信息
			loadPutOutDataList() {
				var that = this;
				that.PutOutDataList = [];
				this.$httpRequest({
					url: `WMS/WmsBillPutOutDetailsBody/GetInv?Sitemcode=${this.selected[0].itemcode}&Slot=${this.selected[0].lot}&pageIndex=${this.POrderOptions.page}&pageSize=${this.POrderOptions.itemsPerPage}`,
					method: 'get'
				}).then(function(response) {
					if (response.status == 1) {
						that.PutOutDataList = response.data.result;
						that.POrderTotalCount = response.data.pagination.totalRecords;						that.POrderLoading = false;
					} else {
						that.$message.error("加载拣配明细失败！");	
					}
				})
			},
			CommitInv(){
				if(this.Pselected.length == 0)
				{
					this.$message.error("请选择1条信息！");	
				}
				else if(this.Pselected.length > 1)
				{
					this.$message.error("请不要多选！");	
				}
				else
				{
					var that = this;
					this.$httpRequest({
						url: `WMS/WmsBillPutOutDetailsBody/OutInv?id=${this.Pselected[0].id}&fatherid=${this.selected[0].id}`,
						method: 'get'
					}).then(function(response) {
						if (response.status == 1) {
							that.$message.success(response.info);	
						} else {
							that.$message.error(response.info);	
						}
					});
					this.PutOutDialog = false;
					this.Pselected = [];
					this.selected = [];
				}
			}
			
  	}
  
  }

</script>

<style>
	$select-small-chips-dense-selections-min-height{
		height:40px;
	}
</style>